<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/admin/common/inc/incSession.jsp" %>
<jsp:include page="/admin/common/inc/Top.jsp" />
<%
	
	String srchNoticeType = util.getStr(request.getParameter("srchNoticeType"));
	String srchCond 	= util.getStr(request.getParameter("srchCond")); 
	String srchContent 	= util.getStr(request.getParameter("srchContent"));
	String srchStdt 	= util.getStr(request.getParameter("srchStdt"));
	String srchEndt 	= util.getStr(request.getParameter("srchEndt"));
	String srchUseYn 	= util.getStr(request.getParameter("srchUseYn"));


	// paging
	String idx 		= util.getStr(request.getParameter("idx"));
	String perRow 		= util.getStr(request.getParameter("perRow"));
	String startRow 	= util.getStr(request.getParameter("startRow"));
	String currentPage 	= util.getStr(request.getParameter("currentPage"));
	
	perRow = "".equals(perRow) ?"10":perRow;
	startRow = "".equals(startRow)?"0":startRow;
	currentPage = "".equals(currentPage)?"1":currentPage;
	
	
// 	param.put("srchCond",srchCond);
// 	param.put("srchContent",srchContent);
// 	param.put("srchStdt",srchStdt);
// 	param.put("srchEndt",srchEndt);
// 	param.put("srchUseYn",srchUseYn);
	
// 	paging
// 	param.put("perRow", perRow);
// 	param.put("startRow", startRow);
	
	
	
	//param.put("startRow",11);
	//param.put("perRow",10);
	
	param.put("idx", idx);	
	HashMap map	 = 	(HashMap)sqlMap.queryForObject("AdminNotice.selectNoticeDetail",param);	//	실행할 SQL ID, 검색조건(없을경우 null)
	
	System.out.println("map : " + map);
	
%>
<script type="text/javascript">
	
	$(document).ready(function() {

		loadContent();
		
		//	초기값 셋팅
		$("#srchNoticeType").val("<%=srchNoticeType%>");
		$("#srchCond").val("<%=srchCond%>");
		$("#srchContent").val("<%=srchContent%>");
		$("#srchStdt").val("<%=srchStdt%>");
		$("#srchEndt").val("<%=srchEndt%>");
		$("#srchUseYn").val("<%=srchUseYn%>");
		$("#startRow").val("<%=startRow%>");
		$("#currentPage").val("<%=currentPage%>");
		$("#idx").val("<%=idx%>");
		
		
		
		//	등록
		$("#btnModify").click(function() {
			
			
			$("#content").val(Editor.getContent());
			$("#detailForm").attr("action","/admin/notice/noticeDetail_u.jsp");
			$("#detailForm").attr("target","hiddenFrame");		
			
			if( !confirm("공지사항를 수정 하시겠습니까?")) return;

			$("#detailForm").submit();
			
		});
		
		/*
		$("#listForm").validate({
			rules: {
				eventType 	: "required",
				categoryCode: "required",
				eventName 	: "required",
				productName	: "required",
				recruitNo   : "required",
				link 		: "required",
				reqFdate 	: "required",
				reqTdate 	: "required",
				reviewFdate : "required",
				reviewTdate : "required",
				winDate 	: "required",
				provideDate : "required",
				useYn 		: "required"
			},
				
		  	messages: {
		  		eventType 	: "<br/>이벤트 타입을 선택하세요.",
				categoryCode: "<br/>카테고리를 선택하세요.",
				eventName 	: "<br/>이벤트명을 입력하세요.",
				productName	: "<br/>상품명을 입력하세요.",
				recruitNo   : "<br/>모집인원일 입력하세요.",
				link 		: "<br/>관련링크를 입력하세요.",
				reqFdate 	: "<br>이벤트 진행기간을 입력하세요.</br>",
				reqTdate 	: "<br>이벤트 진행기간을 입력하세요.</br>",
				reviewFdate : "<br>이벤트 활동기간을 입력하세요.</br>",
				reviewTdate : "<br>이벤트 활동기간을 입력하세요.</br>",
				winDate 	: "<br>당첨자 발표일을 입력하세요.</br>",
				provideDate : "<br>상품 지급일을 입력하세요.</br>",
				useYn 		: "<br/>사용 여부를 선택하세요."
		  },
		  
		  submitHandler: function (frm) {
              frm.submit(); // 통과시 전송
          },
          success: function (e) { 
              //
          }                

          
		});
		*/
		
		//	목록으로
		$("#btnList").click(function() {
			
			$("#listForm").attr("action","/admin/notice/noticeList.jsp");
			$("#listForm").attr("target","_top");		
			$("#listForm").submit();
			
		});
		
		
		//	초기화
		$("#btnReset").click(function() {
			
			$("input").val("");
			$("select").val("");
			
		});
		
	});
		
</script>	
	<body>
		<!-- header -->
		<div id="header">
			<jsp:include page="/admin/common/inc/Header.jsp" />
		</div>
		<!-- //header -->
		
		<!-- wrap -->
		<div id="wrap" >
		
			<!-- contentWrap -->
			<div id="contentWrap" >
			
				<!-- topmenu -->
				<jsp:include page="/admin/common/inc/TopMenu.jsp" />
				<!-- //topmenu -->
				
				
				<div id="conts">
				
					<div class="main_view clfix " style="height: 600px;">
						<!-- content -->
						
						
						<form id="listForm" name="listForm" method="post">
							<input type="hidden" name="srchNoticeType" id="srchNoticeType" value="" />
							<input type="hidden" name="srchCond" id="srchCond" value="" />
							<input type="hidden" name="srchContent" id="srchContent" value="" />
							<input type="hidden" name="srchStdt" id="srchStdt" value="" />
							<input type="hidden" name="srchEndt" id="srchEndt" value="" />
							<input type="hidden" name="startRow" id="startRow" value="" />
							<input type="hidden" name="currentPage" id="currentPage" value="" />
						</form>
						
						<form id="detailForm" name="detailForm" method="post" enctype="multipart/form-data">
						<input type="hidden" name="idx" id="idx" value="" />
						
						<div class="section_main">
							
							<!--btn-->
							<div class="al_right mb20">
								<button type="button" id="btnModify">수정</button>
							</div>
							<!--//btn-->
							
							<!--board input-->
							<table class="bdc_input mb10" id="eventInfo">
								<colgroup><col width="20%"><col width="30%"><col width="20%"><col width="30%"></colgroup>
								<tr>
									<th class="cth">제목</th>
									<td class="ctd" colspan="3">
										<input type="text" name="subject" id="subject" value="<%=util.getStr(map.get("SUBJECT")) %>" style="width:90%;"/>
									</td>
								</tr>
								<tr>
									<th class="cth">공지사항 타입</th>
									<td class="ctd">
										<select id="noticeType" name="noticeType">
										<%
											param.clear();
											param.put("p_code","ET");
											ArrayList rs =	(ArrayList)sqlMap.queryForList("Common.selectCodeList",param);	//	실행할 SQL ID, 검색조건(없을경우 null)
											
											for( int i = 0 ; i < rs.size() ; i++){
										%>
											<option value="<%=util.getStr(((HashMap)rs.get(i)).get("CODE")) %>"><%=util.getStr(((HashMap)rs.get(i)).get("NAME")) %></option>
										<%		
											}
										%>
										</select>
									</td>
									<th class="cth">사용여부</th>
									<td class="ctd">
										<select id="useYn" name="useYn">
											<option value="">선택</option>
											<option value="Y">Y</option>
											<option value="N">N</option>
										</select>
									</td>
								</tr>
								<tr>
									<th class="cth">첨부파일</th>
									<td class="ctd" colspan="3">
										<input type="file" name="img_1" id="img_1" />&nbsp;&nbsp;<a href="/<%=util.getStr(map.get("IMG_1")) %>" target="opener"><%=util.getStr(map.get("IMG_1")) %></a><br/>
										<input type="file" name="img_2" id="img_2" />&nbsp;&nbsp;<a href="/<%=util.getStr(map.get("IMG_2")) %>" target="opener"><%=util.getStr(map.get("IMG_2")) %></a><br/>
										<input type="file" name="img_3" id="img_3" />&nbsp;&nbsp;<a href="/<%=util.getStr(map.get("IMG_3")) %>" target="opener"><%=util.getStr(map.get("IMG_3")) %></a><br/>
										<input type="file" name="img_4" id="img_4" />&nbsp;&nbsp;<a href="/<%=util.getStr(map.get("IMG_4")) %>" target="opener"><%=util.getStr(map.get("IMG_4")) %></a><br/>
									</td>
								</tr>
							</table>
							
							<!--웹에디터 -->
							<div style="display:none;font-size:1px !important;">
								<textarea id="content" alt="내용" name="content" value="">contents</textarea>
							</div>
							<% String content = util.getStr(map.get("CONTENT")).replaceAll("\"","\'");  %>

							<div style="margin:0 auto 0 85px; z-index: 1" >
								<jsp:include page="/editor/editor.jsp" flush="false">
									<jsp:param name="formId" value="detailForm"/>
									<jsp:param name="contentWidth" value="900px" />
									<jsp:param name="contentHeight" value="600px" />
									<jsp:param name="description" value="<%=content%>" />
								</jsp:include>
							</div>
						</div>
						
						<!--//board list-->						
						</form>
						
						<!-- //content -->
						
					</div>
					<!--btn-->
					<div class="al_right mb35">
						<button type="button" id="btnList">목록으로</button>
					</div>
					<!--//btn-->
					
				</div>
				
			</div>
			<!-- //contentWrap -->
			
		</div>
		<%@ include file="/admin/common/inc/Footer.jsp" %>
		
		
		<!-- //wrap -->
		
		
	
	</body>
</html>